From: Eric Dumazet Date: Tue, 4 Jun 2024 18:15:11 +0000 (+0000) Subject: net/sched: taprio: always validate TCA_TAPRIO_ATTR_PRIOMAP X-Git-Tag: archive/raspbian/6.1.106-3+rpi1~1^2^2~44 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=4c624fd8a66e90babfb5e5a1fa8b2dffd22f8b23;p=linux.git net/sched: taprio: always validate TCA_TAPRIO_ATTR_PRIOMAP Origin: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/commit?id=3e102bb4e13ae49c014096f149ed0c8430e3c1f0 Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2024-36974 [ Upstream commit f921a58ae20852d188f70842431ce6519c4fdc36 ] If one TCA_TAPRIO_ATTR_PRIOMAP attribute has been provided, taprio_parse_mqprio_opt() must validate it, or userspace can inject arbitrary data to the kernel, the second time taprio_change() is called. First call (with valid attributes) sets dev->num_tc to a non zero value. Second call (with arbitrary mqprio attributes) returns early from taprio_parse_mqprio_opt() and bad things can happen. Fixes: a3d43c0d56f1 ("taprio: Add support adding an admin schedule") Reported-by: Noam Rathaus Signed-off-by: Eric Dumazet Acked-by: Vinicius Costa Gomes Reviewed-by: Vladimir Oltean Link: https://lore.kernel.org/r/20240604181511.769870-1-edumazet@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Gbp-Pq: Topic bugfix/all Gbp-Pq: Name net-sched-taprio-always-validate-TCA_TAPRIO_ATTR_PRI.patch --- diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 1d4638aa425..41187bbd25e 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -938,16 +938,13 @@ static int taprio_parse_mqprio_opt(struct net_device *dev, { int i, j; - if (!qopt && !dev->num_tc) { - NL_SET_ERR_MSG(extack, "'mqprio' configuration is necessary"); - return -EINVAL; - } - - /* If num_tc is already set, it means that the user already - * configured the mqprio part - */ - if (dev->num_tc) + if (!qopt) { + if (!dev->num_tc) { + NL_SET_ERR_MSG(extack, "'mqprio' configuration is necessary"); + return -EINVAL; + } return 0; + } /* Verify num_tc is not out of max range */ if (qopt->num_tc > TC_MAX_QUEUE) {